package com.bnp.reporting.java8.lambda;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * Created by adib on 09/11/14.
 */
public class UseComparator {

    public static void main(String[] args) {

        List<String> names = new ArrayList<>();
        names.add("Tanguy");
        names.add("HongFei");
        names.add("ZhiHei");
        names.add("Stephane");
        names.add("Prachi");
        names.add("Adib");
        names.add("Nokuei");
        names.add("Neeraj");

        Collections.sort(names);
        System.out.println("Simple sort");
        for(String name: names){
            System.out.println(name);
        }

        Collections.sort(names, new Comparator<String>() {
            @Override
            public int compare(String str1, String str2) {
                return str1.compareToIgnoreCase(str2);
            }
        });

        System.out.println("\nSort with comparator:");
        for(String name: names){
            System.out.println(name);
        }
    }
}
